const path = require('path');
const webpack = require('webpack');

module.exports = {
    
    // This is the setting for electron.
    target: "electron",
    
    // This enables the creation of source maps,
    // which improve the debuggability of the application
    // by allowing you to see where an error was raised.
    devtool: "source-map",
    
    // Entry file to startsbuilding from.
    // entry.jsx is the renderer process,
    // main.js is for the main process.
    // Electron will be pointed at the main bundle,
    // while the Renderer will point to entry bundle.
    entry: {
        entry: './app/renderer/entry.jsx',
        main: './app/main/main.js'
    },
    
    // Location and filename pattern of the
    // final build output files.
    output: {
        path: path.join(__dirname, 'build'),
        filename: "[name].bundle.js"
    },

    module: {
        loaders: [
           
            {
                // Babel loader configuration. Performs the JSX and ES6 to JS transformations.
                test: /\.jsx?$/,
                include: path.resolve(__dirname, "app"),
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015']
                },
		        exclude: /node_modules/
            },
			{
                // Post-css loader and its plugins.
                test: /\.scss$/,
                include: path.resolve(__dirname, "app/renderer/styles"),
                loaders: [
                    'style',// inserts raw css into styles elements.
                    'css', // css-loader parses css files resolves url() expressions.
                    'sass' // sass-loader for sass compilation
                ]
            },
            {
               test: /\.(css|less)$/,
               loader: 'style-loader!css-loader!postcss-loader!less-loader'
            },
            {
 			   test: /\.(png|jpg|jpeg|gif)$/,
               loader: 'url-loader?limit=10000&name=./images/[name].[ext]'
            },
			{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file" },
			{ test: /\.json$/, loader: "file" },
			{ test: /\.(woff|woff2)$/, loader:"url?prefix=font/&limit=5000" },
			{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
			{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml" }]
    }
}